<?php
/**
 * Created by JetBrains PhpStorm.
 * User: jh
 * Date: 12-9-26
 * Time: 下午11:48
 * To change this template use File | Settings | File Templates.
 */
class FileLocator implements Locator
{
    protected $base = '.';

    public function __construct($directory='.')
    {
        $this->base = (string) $directory;
    }

    public function canLocate($class)
    {
        $path = $this->getPath($class);

        if (file_exists($path))
        {
            return true;
        }
        else
        {
            return false;
        }
    }

    public function getPath($class)
    {
        return $this->base . '/' . str_replace('_', '/', $class) . '.php';
    }
}